package com.massfords.jaxb;

import java.util.Set;

import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JMod;
import com.sun.codemodel.JPackage;
import com.sun.tools.xjc.outline.ClassOutline;
import com.sun.tools.xjc.outline.Outline;

public class CreateVisitableInterface extends CodeCreator {

    private JDefinedClass mVisitor;

    public CreateVisitableInterface(JDefinedClass aVisitor, Outline aOutline, JPackage aPackage) {
        super(aOutline, aPackage);
        mVisitor = aVisitor;
    }

    @Override
    protected void run(Set<ClassOutline> aClasses) {
        setOutput( mOutline.getClassFactory().createInterface(mPackage, "Visitable", null) );
        getOutput().method(JMod.PUBLIC, void.class, "accept").param(mVisitor, "aVisitor");
        
        for(ClassOutline classOutline : aClasses) {
            classOutline.implClass._implements(getOutput());
        }
    }

}
